package com.fastadmin.interceptor;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.fastadmin.common.FAConst;
import com.fastadmin.common.cookie.CookieUtils;
import com.fastadmin.common.mapper.JsonMapper;
import com.fastadmin.pojo.FUser;
import com.fastadmin.pojo.User;
import com.fastadmin.service.FUserService;
import com.fastadmin.thread.UserThreadLocal;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.qiniu.util.Auth;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserLoginHandlerInterceptor implements HandlerInterceptor {
    private static final Logger logger = LoggerFactory.getLogger(UserLoginHandlerInterceptor.class);
    protected static JsonMapper binder = JsonMapper.nonDefaultMapper();
    @Autowired
    private FUserService userService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        logger.debug("{}", request.getRequestURI());
       /* String auth = ServletUtil.getHeader(request, "auth", CharsetUtil.UTF_8);
        FUser fUser = userService.queryUserByToken(auth);
        if (ObjectUtil.isNull(fUser)) {
            return false;
        } else {
            return true;
        }*/
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    }





}